// MouseMsgHandlerImpl.h : header file

#pragma once

#include "TrayIcon.h"
#include "TrayIconMouseMsgHandler.h"

// Shows a window
BOOL ShowWnd(CWnd* pWnd)
{
	pWnd->ShowWindow(SW_SHOWNORMAL);
	pWnd->SetForegroundWindow();
	return true;
}


// Shows a popup menu
void ShowPopupMenu(CWnd* pWnd, unsigned int uResourseID, int nSubMenuPos)
{
	CPoint aPos;
	GetCursorPos(&aPos);
	CMenu aMenu;
	aMenu.LoadMenu(uResourseID);		
	aMenu.GetSubMenu(nSubMenuPos)->TrackPopupMenu(TPM_RIGHTALIGN | TPM_RIGHTBUTTON, aPos.x, aPos.y, pWnd, 0);
}

// Left mouse button double click message handler
class CLeftMouseDblClickMsgHandler: public CTrayIconMouseMsgHandler
{
public:

	CLeftMouseDblClickMsgHandler() : CTrayIconMouseMsgHandler(WM_LBUTTONDBLCLK){}

	void MouseMsgHandler()
	{
		ShowWnd(AfxGetMainWnd());
	}
};

// Right mouse button click message handler
class CRightMouseClickMsgHandler: public CTrayIconMouseMsgHandler
{
public:

	CRightMouseClickMsgHandler() : CTrayIconMouseMsgHandler(WM_RBUTTONDOWN){}

	void MouseMsgHandler()
	{
		ShowPopupMenu(AfxGetMainWnd(), IDR_TASKBAR_MENU, 0);
	}
};

// Mouse hover message handler
class CMouseHoverMsgHandler: public CTrayIconMouseMsgHandler
{
public:

	CMouseHoverMsgHandler(CTrayIcon* pTrayIcon) : CTrayIconMouseMsgHandler(WM_MOUSEFIRST)
	{
		m_pTrayIcon = pTrayIcon;
	}

	void SetTrayIcon(CTrayIcon* pTrayIcon)
	{
		m_pTrayIcon = pTrayIcon;
	}

	void MouseMsgHandler()
	{
	}

private:

	CTrayIcon* m_pTrayIcon;
};